{extends file="template.tpl"}
{* STYLE SHEETS *}
{block name=css}<link rel="stylesheet" href="css/general.css" type="text/css" />
<link rel="stylesheet" href="css/admin.css" type="text/css" />
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="dtree/dtree.js"></script>{/block}

{* LEFT MENU *}
{block name=leftMenu}
    {include file="../snippets/left_menu.tpl"}
{/block}

{* CONTENT *}
{block name=content}
                <h1>Artikel plaatsen</h1>
                <p id="newArticleSectionsParagraph" >Relevante categorie{validate id="fArticleCategory" message="<span class='newArticleError' style='padding-left:50px;' >Selecteer een geldige categorie</span>"}</p>
                <form method="POST" action="admin.php?option=new_article" id="placeArticle">
                    {* CATEGORIES *}
                    <script type="text/javascript">
                    d = new dTree('d');
                    d.config.useLines = false;
                    d.config.useIcons = false;
                    d.add(0,-1,'Hoofdcategorie');
                    {foreach $categories as $category}
                        d.add( {$category->id}, {$category->parentid}, "{$category->name}");
                    {/foreach}
                    
                    document.write(d);
                    </script>
                    <input id="nodeIdSelection" type="hidden" name="articleCategory" value="0" />
                    <p>Onderwerp {validate id="fArticleSubject" message="<span class='newArticleError' style='padding-left:50px;' >Onderwerp mag niet leeg zijn</span>"}
                    <input type="text" id="articleSubject" name="articleSubject" value="{$articleSubject}"/></p>
                    <textarea id="articleText" name="articleText">{$articleText}</textarea>
                    {validate id="fArticleText" message="<p class='newArticleError'>Artikel tekst mag niet leeg zijn</p>"}
                    <p id="buttonParagraph"><input type="submit" value="Uitvoeren" /></p>
                </form>
                
                <script>
                    {* CKEDITOR INITIALISATION *}
                    CKEDITOR.replace( 'articleText' );
                    {* UPDATE HIDDEN FIELD WITH SELECTED NODE *}
                    updateElement(document.getElementById('nodeIdSelection'), d.aNodes[d.selectedNode].id);
                    updateElement(document.getElementById('nodeNameSelection'), d.aNodes[d.selectedNode].name);
                </script>
{/block}